﻿Imports Control_Vuelos_BE
Imports System.Data
Imports System.Data.SqlClient
Imports System.Data.OleDb

Public Class M_TipoVueloADO
    Dim MiConexion As New ConexionADO
    Dim cnx As New SqlConnection(MiConexion.GetCnx)
    Dim cmd As New SqlCommand
    Dim scriterio As String = ""


    Public Function pr_Get_TipoVuelo(ByRef p_CodTipo As String) As M_TipoVueloVE
        Try
            Dim sql As String = "SELECT * FROM dbo.M_TipoVuelo WITH (NOLOCK) "
            scriterio = String.Format(" Where  CodTipo = '{0}'", p_CodTipo.Trim)
            Dim drCurrent As DataRow
            Dim cn As New SqlConnection(MiConexion.GetCnx)
            Dim rstTipo As New M_TipoVueloVE
            Using cn
                Dim da As SqlDataAdapter = New SqlDataAdapter(sql & scriterio, cn)
                Using da
                    cn.Open()
                    Dim dt As DataTable = New DataTable("TVuelo")
                    ' Rellenamos el objeto DataTable
                    da.Fill(dt)
                    For Each drCurrent In dt.Rows
                        rstTipo.CodTipo = drCurrent("CodTipo").ToString
                        rstTipo.NomTipo = drCurrent("NomTipo").ToString
                        rstTipo.CodEmpresa = drCurrent("CodEmpresa").ToString
                        rstTipo.NroCupos = drCurrent("NroCupos").ToString
                    Next
                    Return rstTipo
                End Using
            End Using
        Catch myException As Exception
            MsgBox("M_TipoVueloADO (pr_Get_TipoVuelo) --> " & myException.Message, MsgBoxStyle.Critical)
            Return Nothing
        End Try
    End Function

End Class
